package com.hzdl.house_mgr.controller;

import com.github.pagehelper.PageInfo;
import com.hzdl.house_mgr.bean.LogInfo;
import com.hzdl.house_mgr.service.LogInfoService;
import com.hzdl.house_mgr.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sysLogInfo")
public class LogInfoController {

    @Autowired
    private LogInfoService logInfoService;

    @RequestMapping("logInfo/logInfoRightJson")
    public AjaxResult logInfoRightJson(LogInfo logInfo, Integer page, Integer limit){
        PageInfo<LogInfo> pageInfo = logInfoService.findLogInfoByWhere(logInfo,page, limit);
        Integer count = logInfoService.getCountByWhere(logInfo);
        return AjaxResult.ok(count,pageInfo.getList());
    }

    @RequestMapping("logInfo/logInfoDelete")
    public AjaxResult logInfoDelete(Integer id){
        int i = logInfoService.deleteLogInfoById(id);
        if(i>0){
            return AjaxResult.DEL_SUCCESS();
        }else{
            return AjaxResult.DEL_FAILED();
        }
    }

    @RequestMapping("logInfo/deleteSomeLogInfo")
    public AjaxResult deleteSomeLogInfo(String logInfoIds){
        int i = logInfoService.deleteSomeLogInfo(logInfoIds.split(","));
        if(i>0){
            return AjaxResult.DELSOME_SUCCESS();
        }else{
            return AjaxResult.DELSOME_FAILED();
        }
    }
}
